package com.tzj.tg;

import java.io.IOException;

import utils.DrawUtils;
import utils.SoundUtils;

/**
 * @author honeyrr
 *	配置类
 */
public final class Config {

	// 窗口配置
	public static final String TITLE = "坦克大战";
	public static final int WIDTH = 64 * 18;
	public static final int HEIGHT = 64 * 10;
	public static final int FPS = 50;
	
	// 坦克和子弹
	public static final String TANK_UP = "res/img/tank_u.gif";
	public static final String TANK_DOWN = "res/img/tank_d.gif";
	public static final String TANK_LEFT = "res/img/tank_l.gif";
	public static final String TANK_RIGHT = "res/img/tank_r.gif";
	
	public static final String TANK3_UP = "res/img/enemy_5_u.gif";
	public static final String TANK3_DOWN = "res/img/enemy_5_d.gif";
	public static final String TANK3_LEFT = "res/img/enemy_5_l.gif";
	public static final String TANK3_RIGHT = "res/img/enemy_5_r.gif";
	
	public static final String TANK2_UP = "res/img/tank_2_u.gif";
	public static final String TANK2_DOWN = "res/img/tank_2_d.gif";
	public static final String TANK2_LEFT = "res/img/tank_2_l.gif";
	public static final String TANK2_RIGHT = "res/img/tank_2_r.gif";
	
	public static final String BULLET_UP = "res/img/bullet_u.gif";
	public static final String BULLET_DOWN = "res/img/bullet_d.gif";
	public static final String BULLET_LEFT = "res/img/bullet_l.gif";
	public static final String BULLET_RIGHT = "res/img/bullet_r.gif";
	
	// 墙铁水草
	public static final String WALL = "res/img/wall.gif";
	public static final String WATER = "res/img/water.gif";
	public static final String STEEL = "res/img/steel.gif";
	public static final String GRASS = "res/img/grass.gif";
	
	// 爆炸特效
	public static final String[] SMALL_BLASTS = {"res/img/blast_1.gif","res/img/blast_2.gif",
			"res/img/blast_3.gif","res/img/blast_4.gif"};
	public static final String[] BIG_BLASTS = {"res/img/blast_1.gif","res/img/blast_2.gif",
			"res/img/blast_3.gif","res/img/blast_4.gif","res/img/blast_5.gif","res/img/blast_6.gif",
			"res/img/blast_7.gif","res/img/blast_8.gif"};
	
	// 胜利/失败
	public static final String WIN = "res/img/win.png";
	public static final String OVER = "res/img/over.png";
	
	// 声音
	public static final String START = "res/snd/start.wav";
	public static final String ADD = "res/snd/add.wav";
	public static final String BLAST = "res/snd/blast.wav";
	public static final String FIRE = "res/snd/fire.wav";
	public static final String HIT = "res/snd/hit.wav";
	
	/**
	 * 获取路径图片的size
	 * @param imgPath
	 * @return 
	 */
	public static int[] getImgSize(String imgPath) {
		try {
			return DrawUtils.getSize(imgPath);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 绘制图片
	 * @param imgPath 图片路径
	 * @param x x坐标
	 * @param y y坐标
	 */
	public static void draw(String imgPath, int x, int y) {
		try {
			DrawUtils.draw(imgPath, x, y);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 播放声音
	 * @param sndPath
	 */
	public static void play(String sndPath) {
		try {
			SoundUtils.play(sndPath);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 退出
	 */
	public static void exitGame() {
		//开启子线程3秒后退出虚拟机结束游戏或者你也可以做其他事情,不能在主线程即画图线程退出否则卡
		new Thread(){
			public void run() {
				try {
					Thread.sleep(3000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.exit(0);
			};
		}.start();
	}
}
